import Taro from '@tarojs/taro';
import u from 'updeep'
import request from '../util/request'

export default {
  namespace: 'houseDetail',
  state: {
    listData: {}, // 详细信息
    isShare: false,
    detailData: [{
      name: '办公室',
      code: 'hasOffice',
      isHas: true
    }, {
      name: '牛角',
      code: 'hasNiujiao',
      isHas: true
    }, {
      name: '货梯',
      code: 'hasLift',
      isHas: true
    }, {
      name: '消防等级',
      code: 'fireGrade'
    }], // 详情
    houseType: {
      type: 'workshop',
      text: '厂房'
    },
  },
  reducers: {
    updateState(state, {payload}) {
      return u({
        ...payload
      }, state)
    }
  },
  effects: {
    // 获取列表数据
    * loadDetailData({payload = {}}, { put,call}) {
      let {goodId,type} = payload;
      let url = '/service/' + type + '/'+goodId;
      const {data} = yield call(request, {
        url: SERVERURL + url,
        method: 'get',
      })
      yield put({
        type: 'updateState',
        payload: {
          listData: data.data
        }
      })

    },
  }
};
